package what.basic.file;
import java.net.*;
import java.io.*;
public class ReadURLFile {
	ReadURLFile(String sourceurl, String objectpathfile){

		try {
		URL url=new URL(sourceurl);
		URLConnection c;
		c = url.openConnection();
		BufferedReader buf=new BufferedReader(new InputStreamReader(c.getInputStream()));
		BufferedWriter file=new BufferedWriter(new FileWriter(objectpathfile));
		String line;
		while((line=buf.readLine())!=null){
			System.out.println(line);
			file.write(line);
			file.newLine();
		}
		buf.close();
		file.close();} 
		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void main(String args[]){
		
		new ReadURLFile("http://www.ietf.org/rfc/rfc2396.txt","e:\\1.txt");
		}

}
